package com.hy.admin.security.config;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.hy.admin.security.utils.CommonResult;

/**
 * 说明： CustomOAuth2Exception序列化
 */
public class CustomOAuth2ExceptionSerializer extends StdSerializer<CustomOAuth2Exception> {

	private static final long serialVersionUID = 1L;

	public CustomOAuth2ExceptionSerializer() {
		super(CustomOAuth2Exception.class);
	}

	@Override
	public void serialize(CustomOAuth2Exception value, JsonGenerator gen, SerializerProvider provider) throws IOException {

		ObjectMapper objectMapper=new ObjectMapper();
		
        CommonResult result = value.getResult();
        gen.writeObject(result.toJSONObject());

	}

}
